import cvxpy
import math
# y=x^2
# x[0]=x[0]^2+2x[0]*(x-x[0])
def slove(sig=0.1,step=0.01):
    x1=10
    x2=50
    flag=0
    k=0
    best=1000
    while k<100:
        temp_b=x1*x1
        if temp_b<best:
            best=temp_b
        x=x1
        if x1>0:
            x=(x1*0.5)-step
        elif x1<0:
            x=(x1*0.5)+step
        else:
            break
        x2=x1+sig*(x-x1)
        print("x1:",x1,",x2:",x2);
        if math.fabs(x1-x2)<0.005:
            break;
        x1 = x2


if '__main__'==__name__:
    slove()